package com.chaopei.day35.tools;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.SQLException;

/**
 * @Author yws
 * @Date 2022/4/20 17:43
 */
@ControllerAdvice
public class MyGlobalExceptionHandler {
    @ExceptionHandler(value = Exception.class)
    public void go(HttpServletRequest request,Exception e){
        System.out.println(e.getMessage());
    }
    @ExceptionHandler(value = SQLException.class)
    public void play(HttpServletResponse response,SQLException e){
        System.out.println(e.getMessage());
    }
}
